package com.jshoperxms.controller.mall.backstage.goodscategory;

import com.jshoperxms.Response;
import com.jshoperxms.components.upload.qiniu.ImgFileBean;
import com.jshoperxms.controller.mall.backstage.base.BaseTController;
import com.jshoperxms.controller.mall.backstage.base.IBaseCtrl;
import com.jshoperxms.controller.mall.backstage.base.SearchModel;
import com.jshoperxms.controller.utils.BaseTools;
import com.jshoperxms.controller.utils.DateTools;
import com.jshoperxms.controller.utils.enums.BaseEnums;
import com.jshoperxms.controller.utils.statickey.SerialKeys;
import com.jshoperxms.controller.utils.statickey.StaticKey;
import com.jshoperxms.controller.utils.statickey.TagWords;
import com.jshoperxms.controller.utils.statickey.WarnWrods;
import com.jshoperxms.entity.BrandT;
import com.jshoperxms.entity.GoodsCategoryT;
import com.jshoperxms.service.GoodsCategoryTService;
import com.jshoperxms.service.impl.Serial;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import java.util.*;

/**
 * Created by sdywcd on 16/9/25.
 * Des:
 */
@Controller
@RequestMapping("/mall/goodscategory")
public class GoodsCategoryTController extends BaseTController implements IBaseCtrl<GoodsCategoryT> {

    @Resource
    private GoodsCategoryTService goodsCategoryTService;
    //数据形式
    private Map<String, Object> responsedata = new HashMap<>();

    @RequestMapping(value="/save",method= RequestMethod.POST)
    @Override
    public ResponseEntity save(@RequestBody GoodsCategoryT rq) {
        if (StringUtils.isBlank(rq.getGoodstypeid())||StringUtils.isBlank(rq.getName())||StringUtils.isBlank(rq.getGrade())){
            responsedata.put(TagWords.SUCCESS,false);
            responsedata.put(TagWords.MSG, WarnWrods.ERROR_PARAMS);
        }else{
            if(checkDuplicates(StringUtils.trim(rq.getName()))){
                switch (rq.getGrade()){
                    case "0":
                        saveNav(rq);
                        break;
                    case "1":
                        saveLtype(rq);
                        break;
                    case "2":
                        saveStype(rq);
                        break;
                    default:
                        break;
                }
            }else{
                responsedata.put(TagWords.SUCCESS,false);
                responsedata.put(TagWords.MSG, WarnWrods.ERROR_GOODSCATEGORY_REPEAT_NAME);
            }
        }
        return Response.success(responsedata);
    }

    /**
     * 保存三级分类
     * @param rq
     */
    private void saveStype(GoodsCategoryT rq) {
        GoodsCategoryT bean=new GoodsCategoryT();
        bean.setId(this.serial.Serialid(SerialKeys.GOODSCATEGORY));
        bean.setCreatetime(DateTools.getSystemTimeBi());
        bean.setCreatorid(BaseTools.getAdminCreateId());
        bean.setGoodstypeid(rq.getGoodstypeid());
        bean.setGoodstypename(rq.getGoodstypename());
        bean.setGrade(BaseEnums.CategoryGrade.THIRD.getState());
        bean.setHtmlpath(StaticKey.EMPTY);
        Map<String,String>map=BaseTools.parseImg(rq.getLogo());
        bean.setLogo(map.get(TagWords.NORMALFILEPATH));
        bean.setSlogo(map.get(TagWords.COMPRESSFILEPATH));
        bean.setMetades(rq.getMetades());
        bean.setMetakey(rq.getMetakey());
        bean.setMsync(rq.getMsync());
        bean.setName(rq.getName());
        bean.setParentid(rq.getParentid());
        bean.setParentname(rq.getParentname());
        bean.setPath(rq.getPath());
        bean.setSign(BaseEnums.CategoryGrade.THIRD.getState()+TagWords.UNDERLINE+DateTools.getSystemTimeBi());
        bean.setSort(rq.getSort());
        bean.setStatus(rq.getStatus());
        bean.setUpdatetime(DateTools.getSystemTimeBi());
        bean.setVersiont(1);
        this.goodsCategoryTService.save(bean);
        responsedata.put(TagWords.SUCCESS, true);
        responsedata.put(TagWords.MSG,TagWords.OPERATION_SUCCESS);
    }


    /**
     * 保存二级分类
     */
    private void saveLtype(GoodsCategoryT rq) {
        GoodsCategoryT bean=new GoodsCategoryT();
        bean.setId(this.serial.Serialid(SerialKeys.GOODSCATEGORY));
        bean.setCreatetime(DateTools.getSystemTimeBi());
        bean.setCreatorid(BaseTools.getAdminCreateId());
        bean.setGoodstypeid(rq.getGoodstypeid());
        bean.setGoodstypename(rq.getGoodstypename());
        bean.setGrade(BaseEnums.CategoryGrade.SECOND.getState());
        bean.setHtmlpath(StaticKey.EMPTY);
        Map<String,String>map=BaseTools.parseImg(rq.getLogo());
        bean.setLogo(map.get(TagWords.NORMALFILEPATH));
        bean.setSlogo(map.get(TagWords.COMPRESSFILEPATH));
        bean.setMetades(rq.getMetades());
        bean.setMetakey(rq.getMetakey());
        bean.setMsync(rq.getMsync());
        bean.setName(rq.getName());
        bean.setParentid(rq.getParentid());
        bean.setParentname(rq.getParentname());
        bean.setPath(rq.getPath());
        bean.setSign(BaseEnums.CategoryGrade.SECOND.getState()+TagWords.UNDERLINE+DateTools.getSystemTimeBi());
        bean.setSort(rq.getSort());
        bean.setStatus(rq.getStatus());
        bean.setUpdatetime(DateTools.getSystemTimeBi());
        bean.setVersiont(1);
        this.goodsCategoryTService.save(bean);
        responsedata.put(TagWords.SUCCESS, true);
        responsedata.put(TagWords.MSG,TagWords.OPERATION_SUCCESS);
    }

    /**
     * 保存一级分类
     */
    private void saveNav(GoodsCategoryT rq) {
        GoodsCategoryT bean=new GoodsCategoryT();
        bean.setId(this.serial.Serialid(SerialKeys.GOODSCATEGORY));
        bean.setCreatetime(DateTools.getSystemTimeBi());
        bean.setCreatorid(BaseTools.getAdminCreateId());
        bean.setGoodstypeid(rq.getGoodstypeid());
        bean.setGoodstypename(rq.getGoodstypename());
        bean.setGrade(BaseEnums.CategoryGrade.FIRST.getState());
        bean.setHtmlpath(StaticKey.EMPTY);
        Map<String,String>map=BaseTools.parseImg(rq.getLogo());
        bean.setLogo(map.get(TagWords.NORMALFILEPATH));
        bean.setSlogo(map.get(TagWords.COMPRESSFILEPATH));
        bean.setMetades(rq.getMetades());
        bean.setMetakey(rq.getMetakey());
        bean.setMsync(rq.getMsync());
        bean.setName(rq.getName());
        bean.setParentid(StaticKey.EMPTY);
        bean.setParentname(StaticKey.EMPTY);
        bean.setPath(StaticKey.EMPTY);
        bean.setSign(BaseEnums.CategoryGrade.FIRST.getState()+TagWords.UNDERLINE+DateTools.getSystemTimeBi());
        bean.setSort(rq.getSort());
        bean.setStatus(rq.getStatus());
        bean.setUpdatetime(DateTools.getSystemTimeBi());
        bean.setVersiont(1);
        this.goodsCategoryTService.save(bean);
        responsedata.put(TagWords.SUCCESS, true);
        responsedata.put(TagWords.MSG,TagWords.OPERATION_SUCCESS);
    }



    /**
     *
     * @api {post} /mall/goodscategory/findCategoryAllByParentId 根据父id获取分类信息
     * @apiName 根据父id获取分类信息
     * @apiGroup  GoodsCategoryService
     * @apiDescription 后台管理员根据父id获取分类信息
     * @apiVersion 0.0.1
     * @apiParam {String} parentId 父id
     *
     * @apiSuccess {String} sucflag true标记
     * @apiSuccess {String} msg  提示信息
     * @apiSuccess {List} beanlist 数据集合
     *
     * @apiUse operationError
     * @apiUse operationSuccess
     */
    @RequestMapping(value="/findCategoryAllByParentId",method= RequestMethod.POST)
    public ResponseEntity findAllCategoryByParentId(@RequestBody GoodsCategoryT rq){
        if(StringUtils.isBlank(rq.getId())){
            responsedata.put(TagWords.SUCCESS,false);
            responsedata.put(TagWords.MSG,WarnWrods.ERROR_PARAMS);
        }else{
            Criterion criterion=Restrictions.and(Restrictions.eq("parentid", rq.getId())).add(Restrictions.ne(TagWords.STATUS, BaseEnums.DataUsingState.DEL.getState()));
            List<GoodsCategoryT>list=this.goodsCategoryTService.findByCriteria(GoodsCategoryT.class, criterion, Order.desc(TagWords.UPDATETIME));
            responsedata.put(TagWords.BEANLIST,list);
            responsedata.put(TagWords.SUCCESS, true);
            responsedata.put(TagWords.MSG,TagWords.OPERATION_SUCCESS);
        }
        return Response.success(responsedata);
    }


    /**
     *
     * @api {post} /mall/goodscategory/findNavAll 根据父id获取分类信息
     * @apiName 获取所有一级商品分类
     * @apiGroup  GoodsCategoryService
     * @apiDescription 后台管理员获取所有一级商品分类
     * @apiVersion 0.0.1
     *
     * @apiSuccess {String} sucflag true标记
     * @apiSuccess {String} msg  提示信息
     * @apiSuccess {List} beanlist 数据集合
     *
     * @apiUse operationError
     * @apiUse operationSuccess
     */
    @RequestMapping(value="/findNavAll",method= RequestMethod.POST)
    public ResponseEntity findAllNavCategoryT(){
        Criterion criterion=Restrictions.and(Restrictions.ne(TagWords.STATUS, BaseEnums.DataUsingState.DEL.getState())).add(Restrictions.eq("grade", BaseEnums.CategoryGrade.FIRST.getState()));
        List<GoodsCategoryT>list=this.goodsCategoryTService.findByCriteria(GoodsCategoryT.class, criterion, Order.desc(TagWords.UPDATETIME));
        responsedata.put(TagWords.BEANLIST,list);
        responsedata.put(TagWords.SUCCESS, true);
        responsedata.put(TagWords.MSG,TagWords.OPERATION_SUCCESS);
        return Response.success(responsedata);
    }

    /**
     *
     * @api {post} /mall/goodscategory/findLtypeAll 根据父id获取分类信息
     * @apiName 获取所有二级商品分类
     * @apiGroup  GoodsCategoryService
     * @apiDescription 后台管理员获取所有二级商品分类
     * @apiVersion 0.0.1
     *
     * @apiSuccess {String} sucflag true标记
     * @apiSuccess {String} msg  提示信息
     * @apiSuccess {List} beanlist 数据集合
     *
     * @apiUse operationError
     * @apiUse operationSuccess
     */
    @RequestMapping(value="/findLtypeAll",method= RequestMethod.POST)
    public ResponseEntity findAllLtypeCategoryT(){
        Criterion criterion=Restrictions.and(Restrictions.ne(TagWords.STATUS, BaseEnums.DataUsingState.DEL.getState())).add(Restrictions.eq("grade", BaseEnums.CategoryGrade.SECOND.getState()));
        List<GoodsCategoryT>list=this.goodsCategoryTService.findByCriteria(GoodsCategoryT.class, criterion, Order.desc(TagWords.UPDATETIME));
        responsedata.put(TagWords.BEANLIST,list);
        responsedata.put(TagWords.SUCCESS, true);
        responsedata.put(TagWords.MSG,TagWords.OPERATION_SUCCESS);
        return Response.success(responsedata);
    }


    /**
     *
     * @api {post} /mall/goodscategory/findStypeAll 根据父id获取分类信息
     * @apiName 获取所有三级商品分类
     * @apiGroup  GoodsCategoryService
     * @apiDescription 后台管理员获取所有三级商品分类
     * @apiVersion 0.0.1
     *
     * @apiSuccess {String} sucflag true标记
     * @apiSuccess {String} msg  提示信息
     * @apiSuccess {List} beanlist 数据集合
     *
     * @apiUse operationError
     * @apiUse operationSuccess
     */
    @RequestMapping(value="/findStypeAll",method= RequestMethod.POST)
    public ResponseEntity findAllStypeCategoryT(){
        Criterion criterion=Restrictions.and(Restrictions.ne("status", BaseEnums.DataUsingState.DEL.getState())).add(Restrictions.eq("grade", BaseEnums.CategoryGrade.THIRD.getState()));
        List<GoodsCategoryT>list=this.goodsCategoryTService.findByCriteria(GoodsCategoryT.class, criterion, Order.desc("updatetime"));
        responsedata.put(TagWords.BEANLIST,list);
        responsedata.put(TagWords.SUCCESS, true);
        responsedata.put(TagWords.MSG,TagWords.OPERATION_SUCCESS);
        return Response.success(responsedata);
    }


    /**
     *
     * @api {post} /mall/goodscategory/find 查询一条商品分类
     * @apiName 查询一条的商品分类
     * @apiGroup  GoodsCategoryService
     * @apiDescription 查询一条商品分类
     * @apiVersion 0.0.1
     * @apiSuccess {String} sucflag true标记
     * @apiSuccess {String} msg  提示信息
     * @apiSuccess {BrandT} bean 数据对象
     *
     * @apiUse operationError
     * @apiUse operationSuccess
     */
    @RequestMapping(value="/find",method= RequestMethod.POST)
    @Override
    public ResponseEntity find(@RequestBody GoodsCategoryT rq) {
        if(StringUtils.isBlank(rq.getId())){
            responsedata.put(TagWords.SUCCESS,false);
            responsedata.put(TagWords.MSG,WarnWrods.ERROR_PARAMS);
        }else {
            GoodsCategoryT bean=this.goodsCategoryTService.findByPK(GoodsCategoryT.class,rq.getId());
            if(bean!=null){
                ImgFileBean ifb=new ImgFileBean();
                ifb.setNormalfilepath(bean.getLogo());
                ifb.setCompressfilepath(bean.getSlogo());
                ifb.setBasepath(StaticKey.EMPTY);
                responsedata.put(TagWords.IFB,ifb);
                responsedata.put(TagWords.BEAN,bean);
                responsedata.put(TagWords.SUCCESS,true);
                responsedata.put(TagWords.MSG,TagWords.OPERATION_SUCCESS);
            }else{
                responsedata.put(TagWords.SUCCESS,false);
                responsedata.put(TagWords.MSG,TagWords.INVALIDDATA);
            }
        }
        return Response.success(responsedata);
    }

    /**
     *
     * @api {post} /mall/goodscategory/del 删除商品品牌
     * @apiName 删除商品分类
     * @apiGroup  GoodsCategoryService
     * @apiDescription 后台管理员删除商品分类
     * @apiVersion 0.0.1
     * @apiParam {String} id 商品分类id
     *
     * @apiSuccess {String} sucflag true标记
     * @apiSuccess {String} msg  提示信息
     *
     * @apiUse operationError
     * @apiUse operationSuccess
     */
    @RequestMapping(value="/del",method= RequestMethod.POST)
    @Override
    public ResponseEntity del(@RequestBody GoodsCategoryT rq) {
        if(StringUtils.isBlank(rq.getId())){
            responsedata.put(TagWords.SUCCESS,false);
            responsedata.put(TagWords.MSG,WarnWrods.ERROR_PARAMS);
        }else{
            String ids[]=StringUtils.split(rq.getId(), TagWords.SPLITDOT);
            for(String s:ids){
                GoodsCategoryT bean=this.goodsCategoryTService.findByPK(GoodsCategoryT.class, s);
                if(bean!=null){
                    bean.setStatus(BaseEnums.DataUsingState.DEL.getState());
                    bean.setUpdatetime(DateTools.getSystemTimeBi());
                    this.goodsCategoryTService.update(bean);
                }
            }
            responsedata.put(TagWords.SUCCESS,true);
            responsedata.put(TagWords.MSG,TagWords.OPERATION_SUCCESS);
        }
        return Response.success(responsedata);
    }


    @RequestMapping(value="/update",method= RequestMethod.POST)
    @Override
    public ResponseEntity update(@RequestBody GoodsCategoryT rq) {
        if(StringUtils.isBlank(rq.getId())||StringUtils.isBlank(rq.getGoodstypeid())||StringUtils.isBlank(rq.getName())||StringUtils.isBlank(rq.getGrade())){
            responsedata.put(TagWords.SUCCESS,false);
            responsedata.put(TagWords.MSG, WarnWrods.ERROR_PARAMS);
        }else{
            updateNav(rq);
//           switch (rq.getGrade()) {
//               case "0":
//                   updateNav(rq);
//                   break;
//               case "1":
//                   updateLtype(rq);
//                   break;
//               case "2":
//                   updateStype(rq);
//                   break;
//               default:
//                   break;
//           }
        }
        return Response.success(responsedata);
    }





    /**
     * 更新分类
     * @param rq
     */
    private void updateNav(GoodsCategoryT rq) {
        GoodsCategoryT bean=this.goodsCategoryTService.findByPK(GoodsCategoryT.class,rq.getId());
        if(bean!=null){
            bean.setGoodstypeid(rq.getGoodstypeid());
            bean.setGoodstypename(rq.getGoodstypename());
            bean.setGrade(rq.getGrade());
            Map<String,String>map=BaseTools.parseImg(rq.getLogo());
            bean.setLogo(map.get(TagWords.NORMALFILEPATH));
            bean.setSlogo(map.get(TagWords.COMPRESSFILEPATH));
            bean.setMetades(rq.getMetades());
            bean.setMetakey(rq.getMetakey());
            bean.setMsync(rq.getMsync());
            bean.setName(rq.getName());
            bean.setParentid(rq.getParentid());
            bean.setParentname(rq.getParentname());
            bean.setPath(rq.getPath());
            bean.setSort(rq.getSort());
            bean.setStatus(rq.getStatus());
            bean.setSign(rq.getGrade()+TagWords.UNDERLINE+DateTools.getSystemTimeBi());
            bean.setUpdatetime(DateTools.getSystemTimeBi());
            bean.setVersiont(bean.getVersiont()+1);
            this.goodsCategoryTService.update(bean);
            responsedata.put(TagWords.SUCCESS, true);
            responsedata.put(TagWords.MSG,TagWords.OPERATION_SUCCESS);
        }else{
            responsedata.put(TagWords.SUCCESS,false);
            responsedata.put(TagWords.MSG,WarnWrods.ERROR_PARAMS);
        }

    }


    @Override
    public ResponseEntity findAll() {
        return null;
    }
    /**
     *
     * @api {post} /mall/goodscategory/findByPage 查询分类列表
     * @apiName  查询分类列表
     * @apiGroup  GoodscategoryService
     * @apiDescription 后台管理员查询分类列表 1，区分是否有排序，是否有搜索，然后进行相应的业务方法调用
     * @apiVersion 0.0.1
     * @apiParam {SearchModel} searchModel 搜索模型对象
     * @apiParam {String} search 快捷搜索对象
     * @apiParam {String} ordervalue 排序对象
     * @apiParam {String} ordertype 排序方式
     *
     * @apiSuccess {String} sucflag true标记
     * @apiSuccess {String} msg  提示信息
     * @apiSuccess {map} data 搜索结果对象
     *
     * @apiUse operationError
     * @apiUse operationSuccess
     */
    @RequestMapping(value="/findByPage",method= RequestMethod.POST)
    @Override
    public ResponseEntity findByPage(SearchModel searchModel, @RequestParam("search[value]") String search, @RequestParam("order[0][column]") String ordervalue, @RequestParam("order[0][dir]") String ordertype) {
        findCustomSearch(searchModel,search,ordervalue,ordertype);
        return Response.success(responsedata);
    }

    @Override
    public void findCustomSearch(SearchModel searchModel, String search, String ordervalue, String ordertype) {
        if(searchModel.getIsCustomSearch()==1){
            int currentPage=searchModel.getCalCurrentPage();
            int lineSize = searchModel.getLength();
            Criterion criterion=Restrictions.ne(TagWords.STATUS, BaseEnums.DataUsingState.DEL.getState());
            if(StringUtils.isNotBlank(searchModel.getName())){
                criterion=Restrictions.and(criterion).add(Restrictions.like("name",searchModel.getName(), MatchMode.ANYWHERE));
            }
            if(StringUtils.isNotBlank(search)){
                criterion=Restrictions.and(criterion).add(Restrictions.like("name",search,MatchMode.ANYWHERE));
            }
            int records=this.goodsCategoryTService.count(GoodsCategoryT.class,criterion).intValue();
            searchModel.setRecordsTotal(records);
            searchModel.setRecordsFiltered(records);
            responsedata.put(TagWords.RECORDSTOTAL,records);
            responsedata.put(TagWords.RECORDSFILTERED,records);
            List<GoodsCategoryT> list = this.goodsCategoryTService.findByCriteriaByPage(
                    GoodsCategoryT.class, criterion,Order.desc(TagWords.UPDATETIME), currentPage,
                    lineSize);
            this.processPageList(list);
        }else{
            if(StringUtils.isNotBlank(search)){
                filterSearch(searchModel,search);
            }else{
                findDefaultAll(searchModel,ordervalue,ordertype);
            }
        }
    }

    @Override
    public void filterSearch(SearchModel searchModel, String search) {
        int currentPage=searchModel.getCalCurrentPage();
        int lineSize = searchModel.getLength();
        Criterion criterion=Restrictions.ne(TagWords.STATUS, BaseEnums.DataUsingState.DEL.getState());
        criterion=Restrictions.and(criterion).add(Restrictions.like("name",search,MatchMode.ANYWHERE));
        int records=this.goodsCategoryTService.count(GoodsCategoryT.class,criterion).intValue();
        searchModel.setRecordsTotal(records);
        searchModel.setRecordsFiltered(records);
        responsedata.put(TagWords.RECORDSTOTAL,records);
        responsedata.put(TagWords.RECORDSFILTERED,records);
        List<GoodsCategoryT> list = this.goodsCategoryTService.findByCriteriaByPage(
                GoodsCategoryT.class, criterion,Order.desc(TagWords.UPDATETIME), currentPage,
                lineSize);
        this.processPageList(list);
    }

    @Override
    public void findDefaultAll(SearchModel searchModel, String ordervalue, String ordertype) {
        int currentPage=searchModel.getCalCurrentPage();
        int lineSize = searchModel.getLength();
        Criterion criterion=Restrictions.ne(TagWords.STATUS, BaseEnums.DataUsingState.DEL.getState());
        int records=this.goodsCategoryTService.count(GoodsCategoryT.class,criterion).intValue();
        searchModel.setRecordsFiltered(records);
        searchModel.setRecordsTotal(records);
        responsedata.put(TagWords.RECORDSTOTAL,records);
        responsedata.put(TagWords.RECORDSFILTERED,records);
        Order order=BaseTools.orderByParam("name",ordervalue,ordertype);
        List<GoodsCategoryT> list = this.goodsCategoryTService.findByCriteriaByPage(
                GoodsCategoryT.class, criterion,order, currentPage,
                lineSize);
        this.processPageList(list);
    }

    @Override
    public void processPageList(List<GoodsCategoryT> list) {
        List<Map<String, Object>> data = new ArrayList<Map<String, Object>>();
        for(Iterator<GoodsCategoryT> it = list.iterator(); it.hasNext();){
            GoodsCategoryT bean=it.next();
            if(StringUtils.isBlank(bean.getSlogo())){
                bean.setSlogo(bean.getLogo());
            }
            Map<String,Object>cellMap=new HashMap<String, Object>();
            cellMap.put("id", bean.getId());
            cellMap.put("slogo",bean.getSlogo());
            cellMap.put("name", bean.getName());
            cellMap.put("grade", BaseEnums.CategoryGrade.getName(bean.getGrade()));
            cellMap.put("parentname", bean.getParentname());
            cellMap.put("sort", bean.getSort());
            cellMap.put("status", BaseEnums.DataUsingState.getName(bean.getStatus()));
            cellMap.put("updatetime", DateTools.formateLongDateToString(bean.getUpdatetime().longValue()));
            cellMap.put("version", bean.getVersiont());
            data.add(cellMap);
        }
        responsedata.put(TagWords.DATA, data);
    }

    @Override
    public boolean checkDuplicates(String str) {
        if (StringUtils.isBlank(str)){
            return false;
        }
        Criterion criterion= Restrictions.eq("name",str);
        GoodsCategoryT bean=this.goodsCategoryTService.findOneByCriteria(GoodsCategoryT.class,criterion);
        if(bean!=null){
            return false;
        }
        return true;
    }


}
